<!--  


  slot 插槽，怎么在父类中，
  使用子类数据 重新布局UI

-->

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <div id="app">
    <cpn></cpn>

    <cpn>
      <!-- 注意2.5.x以下必须写template -->
      <!-- slot-scope 在2.6.0弃用了，使用 v-slot -->
      <template v-slot='slot'>
        <!-- <span v-for='item in slot.data'>{{item}} </span> -->
        <span>{{slot.data.join(' - ')}}</span>
      </template>
    </cpn>


    <cpn>
      <template v-slot='slot'>
        <span>{{slot.data.join(' * ')}}</span>
      </template>
    </cpn>
  </div>

  <template id='cpn'>
    <div>
      <slot :data='pLanguages'>
        <ul>
          <li v-for='item in pLanguages'>{{item}}</li>
        </ul>
      </slot>
    </div>
  </template>

  <script src="../../js/vue.js"></script>
  <script>
    const cpn = {
      template: '#cpn',
      data() {
        return{
          pLanguages: ['JavaScript', 'C++', 'Java', 'Go', 'Swift']
        }
      }
    }

    const app = new Vue({
      el: '#app',
      data: {

      },
      components: {
        cpn,
      }
    })
  </script>
</body>
</html>